﻿CKEDITOR.dialog.add( 'myDialog', function( editor )
{
	var urls=new Array();
	urls[0]=__ctxPath+"/resource/admin/js/ajaxfileupload.js";
	$importJs(urls,function(){
	});
	return { 
		title : '图片上传',
		minWidth : 400,
		minHeight : 200,
		onOk : function() {
		$.ajaxFileUpload(
				{
					url:__ctxPath+"/front/common/checkLogin.do?cmd=commonAjaxFileUpload", 
					secureuri:false,
					fileElementId:'uploadId',
					anysc:false,
					dataType: 'text',
					success: function (data)
					{
					var _src=data.replace("<pre>","").replace("</pre>","");   
                    if (_src.match(/(^\s*(\d+)((px)|\%)?\s*$)|^$/i)) {   
                        alert('请输入网址或者上传文件');   
                        return false;   
                    }   
                    this.imageElement = editor.document.createElement( 'img' );   
                    this.imageElement.setAttribute( 'alt', '' );   
                    this.imageElement.setAttribute( 'src',__ctxPath+"/"+_src );   
                  //图片插入editor编辑器   
                    editor.insertElement( this.imageElement );   
					},
					error: function ()
					{
						alert("上传图片出错");
					}
				});
		},
		contents : [
			{
				elements :
				[
					{
						type :'html',
						html :'<div>'
								+'<input id="uploadId" name="uploadId" type="file"/>'
								+ '<div>'
					} 
				
				]
			}
		]
	};
} );

